package com.heima.comment.controller;

import com.heima.apis.comment.CommentRepayControllerApi;
import com.heima.comment.service.ComentRepayService;
import com.heima.model.comment.dtos.CommentRepayDto;
import com.heima.model.comment.dtos.CommentRepayLikeDto;
import com.heima.model.comment.dtos.CommentRepaySaveDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/comentRepay")
public class ComentRepayController implements CommentRepayControllerApi {

    @Autowired
    ComentRepayService comentRepayService;

    /**
     * 回复评论时，先加载评论
     * @param dto
     * @return
     */
    @PostMapping("/repay")
    @Override
    public ResponseResult loadCommentRepay(@RequestBody CommentRepayDto dto) {

        return comentRepayService.loadCommentRepay(dto);
    }

    /**
     * 保存评论
     * @param dto
     * @return
     */
    @RequestMapping("/save")
    @Override
    public ResponseResult saveCommentRepay(@RequestBody CommentRepaySaveDto dto) {
        return comentRepayService.saveCommentRepay(dto);
    }

    /**
     * 点赞回复
     * @param dto
     * @return
     */
    @Override
    public ResponseResult saveCommentRepayLike(CommentRepayLikeDto dto) {
        return comentRepayService.saveCommentRepayLike(dto);
    }
}
